/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.etop.beans;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author cjh(358319110@qq.com)
 */
@Entity
@Table(name = "borrow")
public class Borrow {

    private int id;
    private Date lendTime;
    private Date returnTime;
    private User user;
    private Goods goods;
    private int isReturn;               // 是否归还(0表示为归还，1表示已归还)F

    public Borrow() {
        this.isReturn = 0;
    }

    public Borrow(Date lendTime, Date returnTime, User user, Goods goods) {
        this.lendTime = lendTime;
        this.returnTime = returnTime;
        this.user = user;
        this.goods = goods;
        this.isReturn = 0;
    }

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    @Column(name = "lend_time")
    public Date getLendTime() {
        return lendTime;
    }

    @Column(name = "re_time")
    public Date getReturnTime() {
        return returnTime;
    }

    @ManyToOne
    @JoinColumn(name = "u_id")
    public User getUser() {
        return user;
    }

    @OneToOne
    @JoinColumn(name = "g_id")
    public Goods getGoods() {
        return goods;
    }

    @Column(name = "isreturn")
    public int getIsReturn() {
        return isReturn;
    }

    public void setIsReturn(int isReturn) {
        this.isReturn = isReturn;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setLendTime(Date lendTime) {
        this.lendTime = lendTime;
    }

    public void setReturnTime(Date retuenTime) {
        this.returnTime = retuenTime;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    @Override
    public String toString() {
        return "Borrow{" + "id=" + id + ", returnTime=" + returnTime + ", user=" + user + ", goods=" + goods + '}';
    }
}
